<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微商工具宝</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 100vw;
            min-height: 100vh;
            background: #303643;
        }

        .btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translateX(-50%) translateY(-50%);
            color: #fff;
            font-size: 16px;
        }
        .btn .btnurl{
            width: 150px;
            height: 50px;
            background: #497be5;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
        }
        .btn2{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translateX(-50%) translateY(-50%);
            width: 150px;
            height: 50px;
            background: #497be5;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 16px;
            display: none;
        }

        .download {
            font-size: 18px;
            text-decoration: none;
            color: #fff;
        }
        .op{
            color: #fff;
        }
        svg path{
            fill: #ffffff;
        }
        svg{
            animation: slidein linear 1s infinite;
        }
        @keyframes slidein {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
        }
        #load2{
            display: none;
        }
        #load1{
            margin-top: 10px;
        }
        .loading{
            display: none;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="btn">
            <div>当前最新版本: <span class="versio"></span></div>
            
            <div id="load2" class="btnurl">下载地址</div>
        </div>

        
        
    </div>

  

    <script>
        

        var apkurl = 'https://gitee.com/api/v5/repos/zishichubei/updataapp/git/trees/master?access_token=287f0567853179df022f929c1409db3c'
        var loadurl=''
        fetch(apkurl).then((res)=>{
            return res.json()
        }).then((json)=>{
            console.log('json',json);
            
            json.tree.forEach(ele => {
               
                if(ele.path == 'version.json'){
                    console.log('ele.sha',ele.sha);
                    
                    fetch(`https://gitee.com/api/v5/repos/zishichubei/updataapp/git/blobs/${ele.sha}?access_token=3358736c660cba9e966c19cb3eeb808d`)
                    .then(async(response)=>{
                        // console.log('response',await response.json());
                        
                        const data = await response.json()
                        function base64ToText(base64Data) {
                        const binaryString = window.atob(base64Data);
                        const byteArray = new Uint8Array(binaryString.length);
                        
                        for (let i = 0; i < binaryString.length; i++) {
                            byteArray[i] = binaryString.charCodeAt(i);
                        }
                        const decoder = new TextDecoder('utf-8');
                        return decoder.decode(byteArray);
                        }

                        // 示例使用 base64 编码的数据
                        const base64Data = data.content;

                        const decodedText = base64ToText(base64Data);

                        
                        console.log('url',JSON.parse(decodedText));
                        
                        appdata=JSON.parse(decodedText)
                        loadurl=appdata.downpath
                        window.location.href = loadurl

                        
                    })
                    .catch((err)=>{
                        console.log('err',err);
                        
                    })
                }
                
                
            });
        })


       

        
        
    </script>

</body>

</html>